How does GstRrBrowserSink work
The RidgeRun GStreamer Browser Sink documentation from RidgeRun is presently being developed. |
How does GStreamer Browser Sink work?
GStreamer Browser sink is a GStreamer Bin. In other words, is an element that can contain other Element, allowing them to be managed as a group. Therefore, GStreamer Browser Sink is composed by WebRTC-style transport elements (ICE, DTLS, SRTP), Custom SDP for Chrome and Internal web server to host the client web app.
Following, you can find a brief explanation on how it works.
Certificate Creation
GStreamer Browser Sink generates a self-signed TLS certificate and private key. This is required to encrypt the media using DTLS-SRTP (secure transport).
SDP (Session Description Protocol) Generation
Creates an SDP offer describing the media stream (video over RTP). This SDP includes:
- Codec (H.264)
- ICE credentials
- Media format
- Fingerprint for DTLS
Following you can find the SDP used by the element.
v=0\r\n o=- 0 0 IN IP4 127.0.0.1\r\n" s=RidgeRun GStreamer Browser Sink\r\n t=0 0\r\n a=group:BUNDLE 0\r\n a=msid-semantic: WMS *\r\n m=video 9 UDP/TLS/RTP/SAVPF %d\r\n c=IN IP4 0.0.0.0\r\n a=rtcp:9 IN IP4 0.0.0.0\r\n a=ice-ufrag:%s\r\n a=ice-pwd:%s\r\n a=fingerprint:sha-256 11:02:22:08:2C:B6:BA:42:34:48:96:25:38:0D:A0:C0:8B: 63:E0:13:C9:87:74:61:1C:FA:1C:FC:86:27:EE:40\r\n a=setup:passive\r\n a=mid:0\r\n a=sendonly\r\n a=rtcp-mux\r\n a=rtcp-rsize\r\n a=rtpmap:%d H264/90000\r\n a=rtcp-fb:%d nack\r\n a=fmtp:%d level-asymmetry-allowed=1;packetization-mode=1; profile-level-id=42c015\r\n
ICE Candidate Gathering
GStreamer Browser Sink uses libnice to gather local ICE candidates. These define possible network paths for the media stream. This list of candidates is added to the SDP.
Web Server to Serve Web Page
GStreamer Browser Sink has a built-in HTTP server serves the HTML/JS page that runs in the browser. It serves the corresponding file (e.g. index.html, JavaScript) and blocks unsafe or invalid paths (basic security checks).
Pipeline Setup
As GStreamer Browser Sink is a GStreamer bin, it sets up a pipeline with the following elements:
- rtpbin: handles RTP session
- dtlssrtpenc/dec: encrypts/decrypts RTP with DTLS
- rtph264pay: payloads the video as H264 RTP with minimal delay.
- nicesink/nicesrc: sends/receives data via ICE to the browser.
Pad Exposure
By exposing the Sink pad, makes possible to connect GStreamer Browser Sink into your pipeline like any other element.